// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init()
const db = cloud.database()
// 云函数入口函数
exports.main = async (event, context) => {
    let {userInfo,stu_array} = event;
    let stu_num = stu_array[0]
    for(var i = 1; i<197; i++){
        console.log(i)
        if(stu_array[i] != '0'){
            temp_day = parseInt((i-1)/28);
            temp_time = (i-1)%28;
            console.log(temp_day,temp_time)
            var index = temp_time+''
            db.collection('data').where({
                time:temp_day
            }).update({
                data:{
                    [index]:stu_num
                }
            })
            db.collection('info_data').where({
                time:temp_day
            }).update({
                data:{
                    [index]:stu_array[i]
                }
            })
    }}
    // return {
    //     event,
    //     openid: wxContext.OPENID,
    //     appid: wxContext.APPID,
    //     unionid: wxContext.UNIONID,
    // }
}